package com.easyxu.kubernetes.filebrowser.service.executor;

import io.kubernetes.client.openapi.ApiException;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.stream.Collectors;

@Component
public class NamespaceQryCmdExe {

    public List<String> execute(){
        CoreV1Api api = new CoreV1Api();
        try {
            return api.listNamespace(null,null,null,null,null,null,null,null,null)
                    .getItems().stream().map(n->n.getMetadata().getName()).collect(Collectors.toList());
        } catch (ApiException e) {
            throw new RuntimeException(e);
        }
    }
}
